<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Mingwpy distribution &#8212; mingwpy 0.1 documentation</title>
    
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '0.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Roadmap" href="roadmap.html" />
    <link rel="prev" title="How to correctly link to UCRT (and why it works that way)" href="ucrt.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head>
  <body role="document">
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="mingwpy-distribution">
<h1>Mingwpy distribution<a class="headerlink" href="#mingwpy-distribution" title="Permalink to this headline">¶</a></h1>
<div class="section" id="what-is-it">
<h2>What is it?<a class="headerlink" href="#what-is-it" title="Permalink to this headline">¶</a></h2>
<p>mingwpy is a mingw-w64 gcc toolchain customized for building Python
extensions.</p>
<p>See <a class="reference internal" href="issues.html"><span class="doc">Issues</span></a> for the need of the various customizations.</p>
</div>
<div class="section" id="where-is-it">
<h2>Where is it?<a class="headerlink" href="#where-is-it" title="Permalink to this headline">¶</a></h2>
<p>Latest versions should be at the <a class="reference external" href="https://anaconda.org/carlkl/mingwpy">mingwpy anaconda site</a>.</p>
<p>There are older versions at the <a class="reference external" href="https://bitbucket.org/carlkl/mingw-w64-for-python/downloads">mingwpy bitbucket repo</a>.</p>
</div>
<div class="section" id="what-s-in-it">
<h2>What&#8217;s in it?<a class="headerlink" href="#what-s-in-it" title="Permalink to this headline">¶</a></h2>
<p>See <a class="reference internal" href="#notes">notes</a> below.</p>
<p>See <a class="reference internal" href="mingwpy_older.html"><span class="doc">Mingwpy retired bitbucket site</span></a> for lists of files in the (older) distribution.</p>
</div>
<div class="section" id="customizations-over-standard-mingw-builds-releases">
<h2>Customizations over standard mingw-builds releases<a class="headerlink" href="#customizations-over-standard-mingw-builds-releases" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>two dedicated GCC toolchains for both 32bit (POSIX threads, Dwarf
exceptions) and 64 bit (POSIX threads, SEH exceptions);</li>
<li>statically built toolchain based on gcc and mingw-w64;</li>
<li>languages: C, C++, gfortran, with <a class="reference internal" href="glossary.html#term-lto"><span class="xref std std-term">LTO</span></a> enabled;</li>
<li>customized &#8216;specs&#8217; file for MSVCR90 linkage and manifest support (MSVCR100
linkage coming soon);</li>
<li>additional ftime64 patch to allow winpthreads and OpenMP to work with
MSVCR90 linkage;</li>
<li>OpenBLAS with windows thread support (OpenMP disabled) included.</li>
</ul>
</div>
<div class="section" id="notes-for-the-distribution">
<span id="notes"></span><h2>Notes for the distribution<a class="headerlink" href="#notes-for-the-distribution" title="Permalink to this headline">¶</a></h2>
<div class="section" id="libpython-import-files">
<h3>libpython import files<a class="headerlink" href="#libpython-import-files" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">libpython27.a</span></code> import files have been generated with <code class="docutils literal"><span class="pre">gendef</span></code> and
<code class="docutils literal"><span class="pre">dlltool</span></code> according to the recommendations on the mingw-w64 faq site. It is
essential to not use import libraries from anywhere, but create them with the
tools in the GCC toolchain. The GCC toolchains contain correct generated
<code class="docutils literal"><span class="pre">mscvrXXX</span></code> import files by default.</p>
</div>
<div class="section" id="openblas-files">
<h3>OpenBLAS files<a class="headerlink" href="#openblas-files" title="Permalink to this headline">¶</a></h3>
<p>The openblas DLL must be copied to numpy/core before building numpy. All Blas
and Lapack code will be linked dynamically to this DLL.  Because of this the
overall distro size gets much smaller compared to numpy-MKL or scipy-MKL. It is
not necessary to add numpy/core to the path!  (at least on my machine). To load
libopenblas.dll to the process space it is only necessary to import numpy –
nothing else. libopenblas.dll is linked against the msvcr90.dll, just like
python. The DLL itself is a fat binary containing all optimized kernels for
all supported platforms. DLL, headers and import files have been included into
the toolchain.</p>
</div>
</div>
<div class="section" id="compiling-numpy-and-scipy">
<h2>Compiling numpy and scipy<a class="headerlink" href="#compiling-numpy-and-scipy" title="Permalink to this headline">¶</a></h2>
<div class="section" id="compiling-numpy">
<h3>Compiling numpy<a class="headerlink" href="#compiling-numpy" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p class="first">&lt;mingw&gt;bin and python should be in the PATH. Choose 32 bit or 64 bit architecture.</p>
</li>
<li><p class="first">copy libpython27.a to &lt;python&gt;libs check, that &lt;python&gt;libs does not
contain libmsvcr90.a</p>
</li>
<li><p class="first">apply numpy.patch</p>
</li>
<li><p class="first">copy libopenblas.dll from &lt;mingw&gt;bin to numpycore of course don&#8217;t ever mix
32bit and 64 bit code</p>
</li>
<li><p class="first">create a site.cfg in the numpy folder with the absolute path to the mingw
import files/header files. I copied the openblas header files, importlibs
into the GCC toolchain.</p>
</li>
<li><p class="first">create a mingw distutils.cfg file</p>
</li>
<li><p class="first">test the configuration:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">config_fc</span> <span class="o">--</span><span class="n">verbose</span>
<span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">build</span> <span class="o">--</span><span class="n">help</span><span class="o">-</span><span class="n">fcompiler</span>
</pre></div>
</div>
</li>
<li><p class="first">build:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">build</span> <span class="o">--</span><span class="n">fcompiler</span><span class="o">=</span><span class="n">gnu95</span>
</pre></div>
</div>
</li>
<li><p class="first">make a exe installer:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">bdist</span> <span class="o">--</span><span class="nb">format</span><span class="o">=</span><span class="n">wininst</span>
</pre></div>
</div>
</li>
<li><p class="first">make a wheel:</p>
<p>Example for built 32-bit exe installer:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wininst2wheel</span> <span class="n">numpy</span><span class="o">-</span><span class="mf">1.8</span><span class="o">.</span><span class="mf">0.</span><span class="n">win32</span><span class="o">-</span><span class="n">py2</span><span class="o">.</span><span class="mf">7.</span><span class="n">exe</span>
</pre></div>
</div>
</li>
<li><p class="first">install:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">wheel</span> <span class="n">install</span> <span class="n">numpy</span><span class="o">-</span><span class="mf">1.8</span><span class="o">.</span><span class="mi">0</span><span class="o">-</span><span class="n">cp27</span><span class="o">-</span><span class="n">none</span><span class="o">-</span><span class="n">win32</span><span class="o">.</span><span class="n">whl</span>
</pre></div>
</div>
</li>
<li><p class="first">test:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">c</span> <span class="s1">&#39;import numpy; numpy.test()&#39;</span>
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="compiling-scipy">
<h3>Compiling scipy<a class="headerlink" href="#compiling-scipy" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p class="first">apply scipy.patch</p>
</li>
<li><p class="first">Check fortran compiler with:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">build</span> <span class="o">--</span><span class="n">fcompiler</span><span class="o">=</span><span class="n">gnu95</span>
</pre></div>
</div>
<p>and a second time:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">build</span> <span class="o">--</span><span class="n">fcompiler</span><span class="o">=</span><span class="n">gnu95</span>
</pre></div>
</div>
</li>
<li><p class="first">Build exe installer:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">bdist</span> <span class="o">--</span><span class="nb">format</span><span class="o">=</span><span class="n">wininst</span>
</pre></div>
</div>
</li>
<li><p class="first">install</p>
</li>
<li><p class="first">test with:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">scipy</span><span class="p">;</span> <span class="n">scipy</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</pre></div>
</div>
</li>
</ol>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Mingwpy distribution</a><ul>
<li><a class="reference internal" href="#what-is-it">What is it?</a></li>
<li><a class="reference internal" href="#where-is-it">Where is it?</a></li>
<li><a class="reference internal" href="#what-s-in-it">What&#8217;s in it?</a></li>
<li><a class="reference internal" href="#customizations-over-standard-mingw-builds-releases">Customizations over standard mingw-builds releases</a></li>
<li><a class="reference internal" href="#notes-for-the-distribution">Notes for the distribution</a><ul>
<li><a class="reference internal" href="#libpython-import-files">libpython import files</a></li>
<li><a class="reference internal" href="#openblas-files">OpenBLAS files</a></li>
</ul>
</li>
<li><a class="reference internal" href="#compiling-numpy-and-scipy">Compiling numpy and scipy</a><ul>
<li><a class="reference internal" href="#compiling-numpy">Compiling numpy</a></li>
<li><a class="reference internal" href="#compiling-scipy">Compiling scipy</a></li>
</ul>
</li>
</ul>
</li>
</ul>

<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2015-2016, Carl Kleffner and collaborators.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.5.1</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.9</a>
      
      |
      <a href="https://github.com/mingwpy/mingwpy.github.io/edit/source/mingwpy.rst"
          rel="nofollow">Edit on GitHub</a>
    </div>

    
    <a href="https://github.com/mingwpy/mingwpy.github.io" class="github">
        <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"  class="github"/>
    </a>
    

    
  </body>
</html>